﻿
@{
    Layout = "";
}

<div ng-controller="GroupHeadListController">
    <div ng-show="reddit.items.length>0" infinite-scroll='reddit.nextPage()' infinite-scroll-disabled='reddit.busy' infinite-scroll-distance='0'>
        <div class="flayout_h_eachBox" ng-repeat="model in reddit.items">
            <div class="flayout_h_hdBox">
                <div class="flayout_h_hdheader"><img src="{{model.UserHeadImg}}"></div>
                <div class="flayout_h_hdright">
                    <p class="flayout_h_userName">{{model.UserName}}</p>
                    @* <p class="flayout_h_personNum">发起10人团</p>*@
                </div>
            </div>
            <div class="flayout_h_groupPro">
                <div class="flayout_h_proimg">
                    <img src="{{ImgHostUrl+model.ProductImgUrl}}">
                </div>
                <div class="flayout_h_proInfo">
                    <p class="flayout_h_proName">{{model.GropGroupTitle}}</p>
                    <div class="flayout_h_proPrice">

                        <label class="txt3">起始价</label><span class="txt1">¥{{model.StartingPrice}}</span>
                        <label class="txt3">抄底价</label><span class="txt1">¥{{model.FloorPrice}}</span>
                    </div>
                </div>
            </div>
            <!-- 已有的拼团人数 -->
            <div class="flayout_h_groupPersonNum">
                <div class="flayout_h_groupPersonNumHd">
                    <span class="h_line_span"></span><label class="h_hd_txt1">已有{{model.InvolvedNum}}人参加</label><label class="h_hd_txt2">现价：¥{{model.NowPrice}}&nbsp;&nbsp;参加1人减&nbsp;¥{{model.DropPrice}}</label><span class="h_line_span"></span>
                </div>
                <div ng-repeat="member in model.Members">
                    <img ng-show="$index<1" src="{{member.UserHeadImg}}" class="hd_group_header" >
                </div>
                <a href="javascript:void(0)" ng-click="gogroupinfo(model.GroupHeadID)" class="look_details">查看详情</a>
                <div class="h_bd">
                    <span class="h_bd_txt1">剩余团有效时间：</span>
                    <label class="h_bd_txt2 ftz_time_part" EndTime="{{model.EndTime}}"></label>
                </div>
            </div>
            <!--end 已有的拼团人数 -->
            <!-- 按钮 -->
            <p class="h_btn"  ng-click="goopen(model.GroupHeadID)">我要参团</p>
            <!-- 按钮 -->
        </div>
        @*<div class="flayout_h_eachBox">
                <div class="flayout_h_hdBox">
                    <div class="flayout_h_hdheader"><img src="/Content/images/f_52.png"></div>
                    <div class="flayout_h_hdright">
                        <p class="flayout_h_userName">张帅生爱神</p>
                        <p class="flayout_h_personNum">发起10人团</p>
                    </div>
                </div>
                <div class="flayout_h_groupPro">
                    <div class="flayout_h_proimg">
                        <img src="/Content/images/f_29.png">
                    </div>

                    <div class="flayout_h_proInfo">
                        <p class="flayout_h_proName">三只松鼠_ 坚果大礼包1208g零食</p>
                        <div class="flayout_h_proPrice">
                            <label class="txt3">起始价</label><span class="txt1">¥29.01</span>
                            <label class="txt3">抄底价</label><span class="txt1">¥19.01</span>
                        </div>
                    </div>
                </div>
                <!-- 已有的拼团人数 -->
                <div class="flayout_h_groupPersonNum">
                    <div class="flayout_h_groupPersonNumHd">
                        <span class="h_line_span"></span><label class="h_hd_txt1">已有1人参加</label><label class="h_hd_txt2">现价：¥28.01&nbsp;&nbsp;参加1人减&nbsp;¥1</label><span class="h_line_span"></span>
                    </div>
                    <div>
                        <img src="/Content/images/f_52.png" class="hd_group_header">
                    </div>
                    <a href="推荐团详情.html" class="look_details">查看详情</a>
                    <div class="h_bd">
                        <span class="h_bd_txt1">剩余团有效时间：</span>
                        <label class="h_bd_txt2">00小时05分28秒</label>
                    </div>
                </div>
                <!--end 已有的拼团人数 -->
                <!-- 按钮 -->
                <p class="h_btn">我要参团</p>
                <!-- 按钮 -->
            </div>*@
    </div>
</div>

<script>

    App.controller('GroupHeadListController', [
           '$scope', '$http', '$rootScope', 'Reddit', '$stateParams', '$state',
       function ($scope, $http, $rootScope, Reddit, $stateParams, $state) {
           $scope.reddit = new Reddit("/DropGroup/GetGroupHeadListAll", { Take: 5, dropgroupid: $stateParams.Id }, function (response) {
               debugger;
           });
           console.log($scope.reddit);

           $scope.goopen = function (id) {
               $state.go('shop.orderconfirm', { "activityId": $stateParams.Id, "activityType": 2, "groupId": id });
           }


           $scope.gogroupinfo = function (id) {
               $state.go('activity.groupheadinfo', { "Id": id });
           }
           var tt = function () {
               $rootScope.WxShare($rootScope.pageTitle(), '优品三悦', location.href, $rootScope.LogoUrl);
           }

           setTimeout(tt, 1000)
       }]);


    function GetRTime() {
        $(".ftz_time_part").each(function () {
            var e = $(this).attr("EndTime").replace(/-/g, '/');

            var EndTime = new Date(e);

            var NowTime = new Date();
            var t = EndTime.getTime() - NowTime.getTime();
            var d = 0;
            var h = 0;
            var m = 0;
            var s = 0;
            if (t >= 0) {
                d = Math.floor(t / 1000 / 60 / 60 / 24);
                h = Math.floor(t / 1000 / 60 / 60 % 24);
                m = Math.floor(t / 1000 / 60 % 60);
                s = Math.floor(t / 1000 % 60);
            }
            var timetxt = "";
            if (d > 0) {
                timetxt += d + "天";
            }
            if (h > 0) {
                if (h < 10) {
                    h = "0" + h;
                }
                timetxt += " " + h + "小时";
            }
            if (m > 0) {
                if (m < 10) {
                    m = "0" + m;
                }
                timetxt += "：" + m + "分";
            }
            if (s > 0) {
                if (s < 10) {
                    s = "0" + s;
                }
                timetxt += "：" + s + "秒";
            }
            $(this).html(timetxt);
        })
    }

    setInterval('GetRTime()', 1000);
</script>

